<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<script type="text/javascript">
			// 声明对象并赋值
			var obj1 = {
				"employees": [
					{"firstName":"Bill" , "lastName":"Gates" },
					{"firstName":"George" , "lastName":"Bush" },
					{"firstName":"Thomas" , "lastName":"Carter" }
				]
			}

			// 转为json字符串（序列化）
			var jsonResult = JSON.stringify(obj1);
			console.log("对象显示到控制台")
			console.log(obj1)
			console.log("对象序列化之后显示到控制台")
			console.log(jsonResult)
			// {"employees":[{"firstName":"Bill","lastName":"Gates"},{"firstName":"George","lastName":"Bush"},{"firstName":"Thomas","lastName":"Carter"}]}

			// json字符串转为对象（反序列化）
			obj1 = JSON.parse(jsonResult);
			console.log("把反序列化的结果显示到控制台")
			console.log(obj1)
		</script>
	</body>
</html>
